#ifndef KC_CONFIGDBREADER_H__KC
#define KC_CONFIGDBREADER_H__KC

#include <string>
#include "../db/MySQLConnector.h"
#include "../db/DatabaseTable.h"
#include "../db/TableEnums.h"
#include "../filter/cond/Symbol.h"

namespace kc_sf
{
	class ConfigDbReader
	{
		public:
			
			void operator()();

		private:

			MySQLConnector conn;

			void readConfigurationOptions();
			void readRules();
			Logic::Symbol *readCondition( const std::string &id_str, const std::string &type_str ) const;
			Logic::Symbol * createAnrCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createAttachmentCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createDateCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createFromCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createKeywordCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createResentCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createSizeCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createToCondition( const DatabaseRecord &values ) const;
			Logic::Symbol * createValidCondition( const DatabaseRecord &values ) const;
			DatabaseRecord readConditionValues( ConditionType cond_type, const std::string &cond_id_str ) const;

			void checkExpression( const std::string &expression ) const;
	};
}

#endif /* KC_CONFIGDBREADER_H__KC */
